<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生管理系统</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <style>
        fieldset{
            width: 500px;
            padding: 20px;
            border: 2px  solid red;
            border-radius: 30px;
            margin: 180px auto;
        }
    </style>
</head>
<body>
<div  id="app">

    <fieldset>
        <legend>管理员登录 </legend>
        <span class="label label-danger">{{msg}}</span>
        <div class="form-group">
            <label>账号：</label>
            <input   class="form-control"  placeholder="请输入账号"  v-model="info.username">
        </div>
        <div class="form-group">
            <label>密码：</label>
            <input  type="password" class="form-control"   placeholder="请输入密码"  v-model="info.password" >
        </div>
        <button type="submit" class="btn btn-danger btn-block"   @click="login()" >登录</button>
    </fieldset>
</div>
<script>
    var haha = new Vue({
        el:"#app",
        data:{
            info:{ },
            msg:""
        },
        methods:{
            login:function () {
                $.post("/test1/admin/login", haha.info, function (backData) {
                    if(backData.code == 50001){
                        haha.msg = backData.msg;
                    }else if(backData.code == 20001){
                        window.location.href = "/test1/main.html";
                    }
                });
            }
        }
    });
</script>

</body>
</html>